$(function () {
    let contactId = localStorage.getItem("contactId");
    findByCompanyId(contactId);
});

function findByCompanyId(id) {
    let result = myAjax('/back/company/findByContactId','get',{id:id,token:$.cookie("token")});
    setCompanyData(result.companyContactModel);//需要给数据  把后台数据拿到
}

function setCompanyData(data) {
    console.log(data);
    $("#contactId").val(data.id);
    $("#companyName").val(data.companyName);
    $("#adress").val(data.adress);
    $("#phone").val(data.phone);
    $("#email").val(data.email);
    $("#fax").val(data.fax);
    $("#qrCode").val(data.qrCode);
}

function contactEdit() {
    let forData = new FormData();
    forData.append("contactId", $("#contactId").val());
    forData.append("companyName", $("#companyName").val());
    forData.append("adress", $("#adress").val());
    forData.append("phone", $("#phone").val());
    forData.append("email", $("#email").val());
    forData.append("fax", $("#fax").val());
    forData.append("qrCode", $("#qrCode")[0].files[0]);//文件取值
    forData.append("token",$.cookie("token"));
    let result = imgMyAjax('/back/company/contactEdit','post',forData);
    if (result.result === 1) {
        alert("提交成功");
        $("#right").load('/back/company/contactManage.html');
    } else {
        alert("提交失败")
    }
}
function cancelContactEdit() {
    $("#right").load('/back/company/contactManage.html');
}